<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div style="background-color: red;width: 100px;height: 100px;" id="box"></div>
  <script>
    function throttle(fn,delay=100){
      let timer=null;
      return function(){
        if(timer)return;
        timer=setTimeout(()=>{
          fn.apply(this,arguments)
          timer=null
        },delay)
      }
    }
    document.getElementById('box').addEventListener('drag',throttle(function(e){
      console.log(e.offsetX,e.offseY);
    }))

  </script>
</body>
</html>